package com.zs.main.filter;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zs.framework.domain.Result;
import com.zs.common.dto.common.ApiMonitorRequestDTO;
import com.zs.common.dto.common.ApiMonitorResponseDTO;
import com.zs.common.dto.common.MonitorDTO;
import com.zs.common.utils.IPUtils;
import com.zs.common.utils.ServiceContext;
import com.zs.main.config.InitializingApiMonitorConfiguration;
import com.zs.main.config.MyContentCachingRequestWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.core.Ordered;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingResponseWrapper;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.URLDecoder;
import java.text.SimpleDateFormat;

/**
 * Copyright 2020 ZS Network Co., Ltd. All rights reserved.
 * 本文件仅限于正数网络技术有限公司内部传阅，禁止外泄以及用于其他的商业目的。
 * Created by yangning on 2021/8/24.
 */
@Component
@Slf4j
public class RequestReplaceFilter extends OncePerRequestFilter implements Ordered {

    @Override
    protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
        filterChain.doFilter(new MyContentCachingRequestWrapper(httpServletRequest), httpServletResponse);
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
